home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Risc World 3
/
Risc World 3.iso
/
SOFTWARE
/
ISSUE4
/
POWERBASE
/
LABEL
/
!PrintLbls
/
!RunImage
(
.txt
)
< prev
next >
Wrap
RISC OS BBC BASIC V Source
|
2000-03-04
|
32KB
|
1,332 lines
><PrintLbls$Dir>.!RunImage
!PrintLbls:
Steven Haslam 1991-5
Sliding heap manager:
Steven Haslam 1992
Improved font handling by Harriet Bazley 1999
Dialogue boxes altered by Derek Haslam, Dec 1999
TASK 4:$TASK="TASK"
wimpmessages 32
!wimpmessages=1
wimpmessages!4=3
wimpmessages!8=7
wimpmessages!12=&400C0
wimpmessages!16=&400C7
wimpmessages!20=&80147
wimpmessages!24=&400C1
wimpmessages!32=0
"Wimp_Initialise",310,!TASK,"Label printer",wimpmessages
version%,thistask%
wimpy_error(
block% &400
init_vars
setup_heap
load_setup
i_size%=&1000
indirection% i_size%
i_ptr%=indirection%
i_end%=indirection%+i_size%
menublocksize%=&200
menublock% menublocksize%
"OS_File",5,"<PrintLbls$Dir>.Sprites22"
,,,,splen%
create_named_sliding_block(spritesanchor%,splen%+4)
'#privatesprites%=!spritesanchor%
!privatesprites%=splen%+4
"OS_ReadModeVariable",-1,4
,,x%
"OS_ReadModeVariable",-1,5
,,y%
x%=1
y%=1
f$="Sprites22"
f$="Sprites"
"OS_File",255,"<PrintLbls$Dir>."+f$,privatesprites%+4
load_windows
mi_ptr%=i_ptr%
create_menus
create_iconbar
quit%=
erwok%=
wimpy_error(
"Wimp_Poll",1,block%
Reason%
Reason%
1 :
redraww(!block%)
2 :
"Wimp_OpenWindow",,block%
3 :
close_window(!block%)
6 :
mouse(block%!0,block%!4,block%!8,block%!12,block%!16)
8 :
keypress(block%!0,block%!4,block%!20,block%!24)
9 :
menu_choice
17,18 :
message_received
19 :
no_acknowledge
quit%
shut_down
shut_down
lose_fonts
"Wimp_CloseDown"
message_received
fromtask%=block%!4
my_ref%=block%!8
your_ref%=block%!12
message%=block%!16
OSCLI("Set Message$Type "+STR$~message%)
message%
0: quit%=
Message_DataSave
(block%!40=&FFF
block%!40=&DFE)
((block%!20=window%(mainW%,1)
block%!24=3)
(block%!20=-2
block%!24=iconbarI%))
bar_drag%=block%!20=-2
block%!36=-1
block%!0=256
W% $(block%+44)="<Wimp$Scrap>"+
block%!12=my_ref%
block%!16=2
i%=0
256
[! block%!(i%+512)=block%!i%
inputfile$="
None
block%!36=-1
RAMb%=256
RAMb%=block%!36
transfers%=0
block%!36=RAMb%
filesize%=0
f9
!fileanchor%
scrap_sliding_block(fileanchor%)
g9
create_named_sliding_block(fileanchor%,block%!36)
block%!16=6
block%!20=!fileanchor%
block%!24=block%!36
k0
"Wimp_SendMessage",18,block%,fromtask%
Message_DataLoad
(block%!40=&FFF
block%!40=&DFE)
((block%!20=window%(mainW%,1)
block%!24=3)
(block%!20=-2
block%!24=iconbarI%))
bar_drag%=(block%!20=-2)
p#
loadCSV(
getstr(block%+44))
block%!0=256
block%!12=my_ref%
block%!16=4
t0
"Wimp_SendMessage",17,block%,fromtask%
u@
apptrans%
("Remove "+
getstr(block%+44)):apptrans%=
Message_RAMTransmit
RAMTransmit
&400C1:
Message_ModeChange
checkfontsOK
&400C0:
Message_MenuWarning
block%!20<=windows%
W%=block%!20
window%(W%,1)=-1
=
"Wimp_CreateWindow",,window%(W%,2)
window%(W%,1)
block%!20=window%(W%,1)
block%!20=fontM%
FontMenu(font$(1+block%!36)):$fontM%=menutitle$(1+block%!36)
"Wimp_CreateSubMenu",,block%!20,block%!24,block%!28
&400C7:
Message_TaskNameIs
0 inputfile$="Data from "+
getstr(block%+28)
bar_drag%
ask_if_print
5 $
icontextaddr(window%(mainW%,1),2)=inputfile$
inputfile$>=18
rj(window%(mainW%,1),2)
redrawicon(window%(mainW%,1),2)
&80147:
printer changed
window%(mainW%,1)>0
pdriver
mainH%=window%(mainW%,1)
@ $
icontextaddr(mainH%,13)=pdriver$:
redrawicon(mainH%,13)
@ $
icontextaddr(mainH%,14)=pres$ :
redrawicon(mainH%,14)
lighticon(mainH%,9,pdriver%)
wimpy_error(code%,mess$,canquit%)
what%,result%
@%="g10.9"
error_error(
"Hourglass_Smash"
code%>1
mess$+="; code: "+
code%
what%=1
mess$,11)="Fatal error":what%=2
canquit%:mess$+="; (Cancel to quit, OK to continue)":what%+=2
!block%=code%
$(block%+4)=mess$+
"Wimp_ReportError",block%,what%,"Label printer"
,result%
result%=2
shut_down
error_error(erl%,err$)
$+" at line "+
!block%=0
k$(block%+4)="Error in error handler! <sob> : "+err$+" at line "+
erl%+" : trying to close down neatly"
"Wimp_ReportError",block%,2,"Label printer"
shut_down
create_iconbar
block%!0=-1
block%!4=0
block%!8=0
block%!12=68
block%!16=68
block%!20=&3002
$(block%+24)="!PrintLbls"
"Wimp_CreateIcon",,block%
iconbarI%
- Menu procedures BEGIN
tickr(a%,i1%,i2%,ix%)
i%,ia%
ia%=a%+28+24*i1%
i%=i1%
ix%=i%
!ia%=!ia%
!ia%=!ia%
&FFFFFFFE
ia%+=24
sub(m$,m%)="|sub"+
"000000000000"+
(m%),12)+m$
menuitem(text$)
menuflags%,iconflags%,submenu%,indlen%,valid%
menuptr%+24>menend%
255,"No room for primary menu definitions"
valid%=-1
ii%=
indlen%=-1
submenu%=-1
text$=""
menuflags%=8
iconflags%=&07000021
text$,1)="|"
text$,2,3)
"brk":
menuflags%+=2
text$=
text$,5)
"sub":
submenu%=
text$,5,12))
text$=
text$,17)
"lit":
*iconflags%+=(1<<22)*(1-
text$,5,1)))
text$=
text$,6)
"tog":
menuflags%+=
text$,5,1))
text$=
text$,6)
"wri":
text$,5,2)
"sp":indlen%=255:valid%=-1
menuflags%+=%100
text$=
text$,7)
(text$)>menumax% menumax%=
(text$)
menuptr%!0=menuflags%
menuptr%!4=submenu%
menuptr%!8=iconflags%
(text$)>11 indlen%=
(text$)
indlen%<0
$(menuptr%+12)=text$
(menuptr%!8=(menuptr%!8)
%100000000
menuptr%!12=i_ptr%
menuptr%!16=valid%
menuptr%!20=indlen%
i_ptr%+indlen%+1>i_end%
255,"No room for MENU indirection"
$i_ptr%=text$
i_ptr%+=indlen%+1
menuptr%+=24
makemen($block%,menutitle$)
makemen2(block%,menutitle$)
makemen2(mendat%,menutitle$)
menumax%,wasptr%
wasptr%=menuptr%
menumax%=10
menuptr%!20=40
$menuptr%=menutitle$
menuptr%?12=7
menuptr%?13=2
menuptr%?14=7
menuptr%?15=0
maxaddr%=menuptr%+16
menuptr%!24=0
menuptr%+=28
i1%=i%+1
item$=""
i%?mendat%<>
i%?mendat%>=32
item$+=
(i%?mendat%)
i%+=1
i%?mendat%=
"," i%+=1
menuitem(item$)
i%?mendat%<32
%menuptr%!-24=(menuptr%!-24)
!maxaddr%=menumax%*16+32
=wasptr%
open_menu(m%,x%,y%)
MenuBLK%=m%
MenuX%=x%
MenuY%=y%
"Wimp_CreateMenu",,m%,x%,y%
- Menu procedures
create_menus
"Hourglass_On"
menuptr%=menublock%
/%menend%=menublock%+menublocksize%
i_ptr%=mi_ptr%
1TIconM%=
makemen(
sub("Info",infoW%)+",Save setup,Quit","PrintLbls"):I_entries%=3
2shighfontM%=
makemen(
sub(menutitle$(1),55)+","+
sub(menutitle$(2),55)+","+
sub(menutitle$(3),55),"Fonts setup")
The '55's are dummy values which will be replaced by fontM%
once we know what it is (after PROCFontMenu)
5QunitsM%=
makemen("Inches,Points,Millipoints,Centimetres,Millimetres","Units")
6/units%=
"**|in|pt|mp|cm|mm","|"+units$)/3-1
tickr(unitsM%,0,4,units%)
8^mainM%=
makemen(
sub("Fonts",highfontM%)+",Remove CSV,"+
sub("Units",unitsM%),"PrintLbls")
FontMenu("")
checkfontsOK
"Hourglass_Off"
mouse(x%,y%,b%,w%,i%)
-2:
iconbar_click(x%,y%,b%)
window%(mainW%,1):
main_click(x%,y%,b%,w%,i%)
window%(errorW%,1):
error_click(w%,i%)
window%(setupW%,1):
setup_click(b%,w%,i%)
iconbar_click(x%,y%,b%)
open_window(mainW%)
open_menu(IconM%,x%-64,96+40*I_entries%)
error_click(w%,i%)
0,0,1280,1024
i%=3
shut_down
close_window(errorW%)
erwok%=
setup_click(b%,w%,i%)
setupH%
setupH%=w%
write_label_sizes
close_window(setupW%)
write_label_sizes
temp%
d$temp%=
icontextaddr(setupH%,4)
temp%=0
wimpy_error(0,"You must have at least 1 label across!",
no_across%=temp%
f$temp%=
icontextaddr(setupH%,5)
temp%=0
wimpy_error(0,"You must have at least 1 label down!",
no_down%=temp%
h1topmargin=
strtomp($
icontextaddr(setupH%,9))
i2leftmargin=
strtomp($
icontextaddr(setupH%,8))
j-width=
strtomp($
icontextaddr(setupH%,6))
k.height=
strtomp($
icontextaddr(setupH%,7))
l4indentation=
strtomp($
icontextaddr(setupH%,12))
menu_choice
adjust%
choice0%=block%!0
choice1%=block%!4
"Wimp_DecodeMenu",,MenuBLK%,block%,block%+&100,&100
t choice$=
getstr(block%+&100)
"Wimp_GetPointerInfo",,block%+&100
adjust%=(block%!&108)
MenuBLK%
IconM%:
icon_menu(choice0%)
mainM%:
main_menu(choice$,choice0%,choice1%)
fontM%:
"Font_DecodeMenu",0,fontM%,block%,block%+&100,255
$fontM%
|"
menutitle$(1):choice1%=1
}"
menutitle$(2):choice1%=2
~"
menutitle$(3):choice1%=3
font_menu_choice(choice1%,
getstr(block%+&100))
adjust%
MenuBLK%=fontM%
choice0%=0
FontMenu(font$(choice1%)):$fontM%=menutitle$(choice1%)
open_menu(MenuBLK%,MenuX%,MenuY%)
getstr(p%)
p$=""
?p%>31
p%+=1
icon_menu(choice%)
choice%
2: quit%=
save_setup
load_windows
filename$
windows%=4
window%(windows%,2)
window%()=-1
)infoW%=1:mainW%=2:errorW%=3:setupW%=4
*filename$="<PrintLbls$Dir>.Templates3"
"Wimp_OpenTemplate",,filename$
space for window def. = 88 + 32 * no. of icons
proginfoS% 88+32*10
"Wimp_LoadTemplate",,proginfoS%,i_ptr%,i_end%,-1,"progInfo"
,,i_ptr%
window%(infoW%,2)=proginfoS%
mainS% 88+32*25
"Wimp_LoadTemplate",,mainS%,i_ptr%,i_end%,-1,"main"
,,i_ptr%
window%(mainW%,2)=mainS%
mainS%!64=privatesprites%
errorS% 88+32*6
"Wimp_LoadTemplate",,errorS%,i_ptr%,i_end%,-1,"error"
,,i_ptr%
window%(errorW%,2)=errorS%
setupS% 88+32*17
"Wimp_LoadTemplate",,setupS%,i_ptr%,i_end%,-1,"setuplabels"
,,i_ptr%
window%(setupW%,2)=setupS%
setupS%!64=privatesprites%
"Wimp_CloseTemplate"
close_window(index%)
loop%,handle%
index%<=windows%
window%(index%,1)=-1
handle%=window%(index%,1)
handle%=index%
!block%=handle%
"Wimp_CloseWindow",,block%
loop%=1
windows%
window%(loop%,1)=handle%
window_delete(loop%)
!block%=handle%
"Wimp_DeleteWindow",,block%
window%(loop%,1)=-1
loop%=windows%
index%=mainW%
close_window(setupW%)
open_window(index%)
handle%
index%<=windows%
window%(index%,1)=-1
"Wimp_CreateWindow",,window%(index%,2)
window%(index%,1)
window_create(index%)
handle%=window%(index%,1)
handle%=index%
!block%=handle%
"Wimp_GetWindowState",,block%
block%!28=-1
"Wimp_OpenWindow",,block%
redraww(handle%)
index%
index%=
index(handle%,
!block%=handle%
"Wimp_RedrawWindow",,block%
more%
more%
index%
"Wimp_GetRectangle",,block%
more%
index(handle%,error%)
index%,loop%
index%=0
loop%=1
windows%
window%(loop%,1)=handle%
index%=loop%
loop%=windows%
index%=0
error%
255,"Window index not found"
=index%
window_create(index%)
f%,handle%
handle%=window%(index%,1)
index%
mainW%:
f%=1
get_font(f%)
icontextaddr(handle%,2)=inputfile$
inputfile$="
None
inputfile$<18
centre(handle%,2)
rj(handle%,2)
pdriver
icontextaddr(handle%,13)=pdriver$
icontextaddr(handle%,14)=pres$
@%="+g10.3"
icontextaddr(handle%,17)=
namesize+"pt"
icontextaddr(handle%,18)=
addrsize+"pt"
lighticon(handle%,9,pdriver%)
update_fontcontrols
setupW%:
icontextaddr(handle%,9)=
display(topmargin)
icontextaddr(handle%,8)=
display(leftmargin)
icontextaddr(handle%,6)=
display(width)
icontextaddr(handle%,7)=
display(height)
icontextaddr(handle%,12)=
display(indentation)
icontextaddr(handle%,4)=
(no_across%)
icontextaddr(handle%,5)=
(no_down%)
window_delete(index%)
index%
mainW%:
lose_fonts
init_vars
cmtoin=(1/2.540005)
inputfile$="
None
erwok%=
font$(3),font%(3,1)
maxaddrs%=100:maxlines%=20
addr$(maxaddrs%,maxlines%),last%(maxaddrs%)
apptrans%=
namesize=24
addrsize=12
transform% 16,rectangle% 16,plotpos% 8,labelrect% 16
menutitle$(3)
menutitle$(1)="Name"
menutitle$(2)="Address"
menutitle$(3)="Last line"
icontextaddr(wi%,ic%)
q%=block%+&100
q%!0=wi%:q%!4=ic%
"Wimp_GetIconState",,q%
=q%!28
loadCSV(fname$)
"Hourglass_On"
inputfile$<>"
None
scrap_sliding_block(fileanchor%)
"OS_File",5,fname$
,,,,CSVlength%
create_named_sliding_block(fileanchor%,CSVlength%)
"OS_File",255,fname$,!fileanchor%
inputfile$=fname$
window%(mainW%,1)>0
icontextaddr(window%(mainW%,1),2)=inputfile$
inputfile$>=18
rj(window%(mainW%,1),2)
bar_drag%
ask_if_print
checknewfile(CSVlength%)
"Hourglass_Off"
setup_heap
initheaps(1024,8)
D,spritesanchor%=
create_anchor("Sprites")
E+fileanchor%=
create_anchor("File data")
F)fontmenu%=
create_anchor("Font menu")
G,indir%=
create_anchor("indirected data")
redrawicon(w%,i%)
q%=block%+&100
!q%=w%
q%!4=i%
q%!8=0
q%!12=0
"Wimp_SetIconState",,q%
main_click(x%,y%,b%,w%,i%)
WI
22,23,24:
FontMenu(font$(i%-21)):$fontM%=menutitle$(i%-21)
XD
icons 6 to 8 correspond to indices 1 to 3
Y$
in arrays
Z4
open_menu(fontM%,x%-64,y%)
[*
open_menu(mainM%,x%-64,y%)
_l
wimpy_error(0,"Drag a CSV file, type Text (&FFF) or CSV (&DFE), onto this icon to load it.",
`%
inputfile$="
None
aR
wimpy_error(0,"You must have loaded in a file in order to print it!",
print
d"
open_window(setupW%)
save_setup
fD
22,23,24:
FontMenu(font$(i%-21)):$fontM%=menutitle$(i%-21)
g1
open_menu(fontM%,x%-64,y%)
main_menu(choice$,choice0%,
choice1%)
dot%
dot%=
choice$,".")
choice$=
choice$,dot%+1)
dot%=
choice$,".")
choice$=
choice$,dot%+1)
choice0%
block%!8>0
"Font_DecodeMenu",0,fontM%,block%+8,block%+&100,255
font menu is 2nd submenu so font selections start at block%+8
choice1%+=1
so that 'font$(choice1%)' points to right value when we return to PROCmenuchoice
font_menu_choice(choice1%,
getstr(block%+&100))
inputfile$<>"
None
scrap_sliding_block(fileanchor%):!fileanchor%=0
inputfile$="
None
icontextaddr(window%(mainW%,1),2)=inputfile$
centre(window%(mainW%,1),2)
choice1%
0:units$="in"
1:units$="pt"
2:units$="mp"
3:units$="cm"
4:units$="mm"
/units%=
"**|in|pt|mp|cm|mm","|"+units$)/3-1
tickr(unitsM%,0,4,units%)
font_menu_choice(choice1%,font$)
change_font(choice1%,
decodefontmenu(font$))
change_font(area%,font$)
lose_font(area%)
font$(area%)=font$
get_font(area%)
update_fontcontrols
lose_fonts
x%,y%
x%=1
y%=0
font%(x%,y%)
"Font_LoseFont",font%(x%,y%)
font%(x%,y%)=0
lose_font(f%)
y%=0
font%(f%,y%)
"Font_LoseFont",font%(f%,y%)
font%(f%,y%)=0
get_font(f%)
"Font_FindFont",,font$(f%),12*16,12*16
font%(f%,0)
save_setup
setup%
read_font_sizes
%setup%=
("<PrintLbls$Dir>.Setup")
f%=1
#setup%,font$(f%)
@%=&90A
#setup%,
namesize
#setup%,
addrsize
#setup%,
topmargin
#setup%,
leftmargin
#setup%,
width
#setup%,
height
#setup%,
indentation
#setup%,
no_across%
#setup%,
no_down%
#setup%,units$
#setup%
load_setup
setup%
%setup%=
("<PrintLbls$Dir>.Setup")
f%=1
font$(f%)=
#setup%
namesize=
#setup%)
addrsize=
#setup%)
topmargin=
#setup%)
leftmargin=
#setup%)
width=
#setup%)
height=
#setup%)
indentation=
#setup%)
no_across%=
#setup%)
no_down%=
#setup%)
units$=
#setup%
#setup%
update_fontcontrols
handle%,f%
handle%=window%(mainW%,1)
f%=1
icontextaddr(handle%,f%+5)=font$(f%)
!block%=handle%
block%!4=f%+5
%block%!8=(1<<6)+(font%(f%,0)<<24)
block%!12=(1<<6)+(255<<24)
"Wimp_SetIconState",,block%
read_font_sizes
handle%
handle%=window%(mainW%,1)
*namesize=
icontextaddr(handle%,17))
*addrsize=
icontextaddr(handle%,18))
memfile(
pointer%)
getstr(pointer%)
pointer%+=
s$+1
- Business part BEGINS
print
Hcount%,Hfiddle%
bar_drag%
read_font_sizes
"Hourglass_On"
fileptr%=!fileanchor%
filebase%=!fileanchor%
"strsppage%=no_across%*no_down%
addr$()=""
fiddle some blank records to force printing to start in right place
4Hfiddle%=
icontextaddr(window%(mainW%,1),20))
Hfiddle%>strsppage%
wimpy_error(0,"Can't start at label "+
(Hfiddle%)+" - you only have "+
(strsppage%)+" labels on each page!",
=Hfiddle%-=1:
Humans start from 1 but arrays start from 0
Hfiddle%>0
Hcount%=0
Hfiddle%-1:addr$(Hcount%,0)="":last%(Hcount%)=0:
Then subtract another 1 since this is the number of the first label
NOT to be skipped!
<labelN%=Hcount%:
will now be next number after Hfiddle%
(fileptr%-filebase%)<=CSVlength%
! line$=
memfile(fileptr%)+","
line$<>","
line%=0
line$>""
line$,1)=""""
quote%=
line$,
34,2)
$ nextpart$=
line$,2,quote%-2)
line$=
line$,quote%+2)
comma%=
line$,",")
" nextpart$=
line$,comma%-1)
line$=
line$,comma%+1)
% addr$(labelN%,line%)=nextpart$
line%+=1
last%(labelN%)=line%-1
labelN%+=1
labelN%=strsppage%
print_page
labelN%=0
addr$()=""
labelN%>0
print_page
"Hourglass_Off"
show_addrs
i%=0
labelN%-1
j%=0
last%(i%)
addr$(i%,j%)
printing_error(N%,e$)
wimpy_error(N%,"1 """+e$+""" during printing",
"PDriver_AbortJob",file%
#file%
wimpy_error(N%,"2"""+e$+""" during printing",
print_page
OStm,OSlm,OSwd,OSht
("RMEnsure PDriver Error 255 No PDriver module!")
"PDriver_Info"
,xres%,yres%,features%
"PDriver_PageSize"
,xsize%,ysize%
file%=
("printer:")
printing_error(
"PDriver_SelectJob",file%,inputfile$
For PostSciprt printers, declare fonts
features%
(1<<29)
declarefont(font$(1))
A4
font$(2)<>font$(1)
declarefont(font$(2))
BI
font$(3)<>font$(2)
font$(3)<>font$(1)
declarefont(font$(3))
"PDriver_DeclareFont"
OSlm=leftmargin/72000*180
OStm=topmargin/72000*180
OSwd=width/72000*180
OSht=height/72000*180
transform%!00=
fixed16(1)
transform%!04=
fixed16(0)
transform%!08=
fixed16(0)
transform%!12=
fixed16(1)
top=ysize%/72000*180
rectangle%!0=0
rectangle%!4=0
P!rectangle%!8=xsize%/72000*180
rectangle%!12=top
plotpos%!0=0
plotpos%!4=0
"PDriver_GiveRectangle",1,rectangle%,transform%,plotpos%,-256
"PDriver_DrawPage",1,rectangle%
more%,,rect%
more%
xn%=0:yn%=0
x=OSlm:y=top-OStm
l%=0
labelN%
labelrect%!0=x
labelrect%!4=y-OSht
labelrect%!8=x+OSwd
labelrect%!12=y
intersect(rectangle%,labelrect%)
printlabel(l%,x,y)
xn%+=1:x+=OSwd
xn%=no_across%
yn%+=1:xn%=0:x=OSlm:y-=OSht
"PDriver_GetRectangle",,rectangle%
more%,,rect%
"PDriver_EndJob",file%
"XOS_Find",0,file%
CLOSE#file%
declarefont(font_name$)
"PDriver_DeclareFont",,font_name$
printlabel(label%,x%,y%)
loop%,dy%
dy%=namesize/72*180
y%-=dy%
"Font_FindFont",,font$(1),namesize*16,namesize*16
font%(1,1)
"Font_SetFont",font%(1,1)
"ColourTrans_SetFontColours",,-256,0,14
"Font_Paint",,addr$(label%,0),1<<4,x%,y%
"Font_LoseFont",font%(1,1)
x%+=indentation/72000*180
dy%=addrsize/72*180
y%-=dy%*1.2
loop%=1
last%(label%)
loop%=last%(label%)
"Font_FindFont",,font$(3),addrsize*16,addrsize*16
font%(3,1)
font%=font%(3,1)
"Font_FindFont",,font$(2),addrsize*16,addrsize*16
font%(2,1)
font%=font%(2,1)
"Font_SetFont",font%
"ColourTrans_SetFontColours",,-256,0,14
"Font_Paint",,addr$(label%,loop%),1<<4,x%,y%
"Font_LoseFont",font%
loop%=last%(label%)
font%(3,1)=0
font%(2,1)=0
x%+=indentation/72000*180
y%-=dy%
fixed16(N)=N*(2^16)
intersect(boxA%,boxB%)
boxA%!0<=boxB%!0
boxA%!8>=boxB%!0
boxA%!0<boxB%!8
boxA%!8>=boxB%!12
boxA%!4<=boxB%!4
boxA%!12>=boxB%!4
boxA%!4<boxB%!12
boxA%!12>=boxB%!12
- Business part ENDS
no_acknowledge
block%!16
apptrans%=
i%=0
block%!i%=block%!(i%+512)
"Wimp_SendMessage",18,block%,block%!4
apptrans%=
&400C6:
inputfile$="RAM Transfer"
icontextaddr(window%(mainW%,1),2)=inputfile$
centre(window%(mainW%,1),2)
RAMTransmit
filesize%+=block%!24
block%!24=RAMb%
extend_named_sliding_block(fileanchor%,filesize%+RAMb%)
block%!12=my_ref%
block%!16=6
$block%!20=!fileanchor%+filesize%
block%!24=RAMb%
"Wimp_SendMessage",17,block%,fromtask%
block%!0=24
block%!12=0
block%!16=&400C6
block%!20=fromtask%
"Wimp_SendMessage",18,block%
checknewfile(filesize%)
checknewfile(fsize%)
extend_named_sliding_block(fileanchor%,fsize%+1)
file%=!fileanchor%
file%?fsize%=10
file%?(fsize%-1)<>10
fsize%+=1:
checknewfile(fsize%)
CSVlength%=fsize%
pdriver
pdriver%=
xres%,yres%,xres$,yres$
:pdriver$="none installed":pres$="none installed":
"PDriver_Info"
,xres%,yres%,,pdriver$
xres$=
xres%
yres$=
yres%
xres$>
yres$
yres$+=" "
xres$<
yres$
xres$=" "+xres$
pres$=xres$+"
"+yres$
pdriver%=
lighticon(wi%,ic%,co%)
q%=block%+&100
q%!0=wi%
q%!4=ic%
co%
q%!8=0
q%!8=1<<22
q%!12=1<<22
"Wimp_SetIconState",,q%
keypress(w%,i%,s%,k%)
index%,process%
process%=
index%=
index(w%,
index%
mainW%:
main_key(w%,i%,k%)
process%
"Wimp_ProcessKey",k%
main_key(w%,i%,k%)
k%<>13
17,18:
s$,s
s$=$
icontextaddr(w%,i%)
s$,2)="pt"
s>(height/1000)
@%="+g10.3"
i%=17
icontextaddr(w%,i%)=
namesize+"pt"
icontextaddr(w%,i%)=
addrsize+"pt"
"Wimp_SetCaretPosition",-1
wimpy_error(0,"That value is ridiculous! The label itself isn't that high!",
i%=17
namesize=s
addrsize=s
icontextaddr(w%,i%)=
s+"pt"
redrawicon(w%,i%)
main_click(0,0,4,mainW%,9)
simulate click on default icon
process%=
centre(w%,i%)
q%=block%+&100
q%!0=w%
q%!4=i%
q%!8=(1<<3)
q%!12=(1<<3)+(1<<9)
"Wimp_SetIconState",,q%
rj(w%,i%)
q%=block%+&100
q%!0=w%
q%!4=i%
q%!8=(1<<9)
q%!12=(1<<3)+(1<<9)
"Wimp_SetIconState",,q%
mptomm(mp)
mmtomp=(1/25.40005)*72000
=mp/mmtomp
mmtomp(mm)
mmtomp=(1/25.40005)*72000
=mm*mmtomp
strtomp(str$)
srcunits$,number$
srcunits$=
str$,2)
number$=
str$))
srcunits$
"mp":=
number$
"pt":=
number$*1000
"in":=
number$*72000
"mm":=
mmtomp(
number$)
"cm":=
mmtomp(
number$)*10
strtomp(
str$)+units$)
display(mp)
str$,oldf%
oldf%=@%
units$
"in":@%="+g10.3":str$=
(mp/72000)+"in"
"pt":@%="+g10.9":str$=
(mp/1000)+"pt"
"mp":@%="+g10.9":str$=
mp+"mp"
"mm":@%="+g10.3":str$=
mptomm(mp))+"mm"
"cm":@%="+g10.3":str$=
mptomm(mp)/10)+"cm"
@%=oldf%
B =str$
ask_if_print
pdriver
pdriver%=
confirm("Print this CSV file on "+pdriver$+" printer at "+pres$+"?")=
print
confirm(str$)
!block%=0
$(block%+4)=str$+
"Wimp_ReportError",block%,&13,"!PrintLbls, confirm:"
,result%
=result%=1
--- SLIDING HEAP 2.00 PROCEDURES
requires SlidingHeap 2.00
module and PROCs
Steven Haslam 1992
_heap_slotsize
"Wimp_SlotSize",-1,-1
_heap_numtostr(d%,n%)=
d%,"0")+
~n%,d%)
_heap_snumtostr(d%,n%)=
d%," ")+
n%,d%)
heapsinfo
"OS_Heap",1,fixedheapbase%
,,bigbloc%,totfree%
"Fixed heap"
"----- ----"
"Heap base : &";
_heap_numtostr(8,fixedheapbase%)
"Heap size : ";
_heap_bytes2(fixedheapsize%)
"Largest free : ";
_heap_bytes2(bigbloc%)
"Total free : ";
_heap_bytes2(totfree%)
"Sliding heap"
"------- ----"
"SlidingHeap_HeapInfo",slidingheapbase%
_heap_pageup(n%)
"OS_ReadMemMapInfo"
=(n%+R0%-1)
(R0%-1)
initheaps(heapsize%,slidingblocks%)
fixedheapsize%=heapsize%
uLheap_trigger%=
_heap_pageup(
+fixedheapsize%+20+20*slidingblocks%-&8000)
setslotsize(heap_trigger%)
_heap_slotsize<heap_trigger%
130,"Unable to initialise heap"
fixedheapbase%=
y%slidingheapbase%=
+fixedheapsize%
"OS_Heap",0,fixedheapbase%,,fixedheapsize%
"SlidingHeap_Create",slidingheapbase%,2,slidingblocks%
"SlidingHeap_VerifyHeap",slidingheapbase%
_heap_nextfree
nextfree%
"SlidingHeap_NextFree",slidingheapbase%
nextfree%
=nextfree%
destroyheaps
setslotsize(
-&8000)
_heap_wordup(x%)=(x%+3)
create_anchor(name$)
space%
space% 4+
name$+1
!space%=0
$(space%+4)=name$
=space%
create_named_sliding_block(anchor%,size%)
trysize%
size%=
_heap_wordup(size%)
7trysize%=
_heap_pageup(
_heap_nextfree+size%-&7FF4)
trysize%>heap_trigger%
setslotsize(trysize%)
_heap_slotsize<trysize%
%
setslotsize(heap_trigger%)
F
131,"Not enough room to create block """+$(anchor%+4)+""""
heap_trigger%=trysize%
"SlidingHeap_NewBlock",slidingheapbase%,anchor%,size%,anchor%+4
"SlidingHeap_VerifyHeap",slidingheapbase%
scrap_sliding_block(anchor%)
!anchor%=0
"SlidingHeap_ScrapBlock",slidingheapbase%,anchor%
1trysize%=
_heap_pageup(
_heap_nextfree-&7FFC)
trysize%<>heap_trigger%
setslotsize(trysize%)
heap_trigger%=trysize%
!anchor%=0
"SlidingHeap_VerifyHeap",slidingheapbase%
setslotsize(newsize%)
"Wimp_SlotSize",newsize%,-1
extend_named_sliding_block(anchor%,newsize%)
!anchor%=0
create_named_sliding_block(anchor%,newsize%):
!anchor%>
_heap_nextfree
129,"Block beyond heap limits"
$newsize%=
_heap_wordup(newsize%)
"SlidingHeap_DescribeBlock",slidingheapbase%,anchor%
,,oldsize%
larger%=newsize%>oldsize%
larger%
H trysize%=
_heap_pageup(
_heap_nextfree+(newsize%-oldsize%)-&7FFC)
trysize%>heap_trigger%
setslotsize(trysize%)
&
_heap_slotsize<trysize%
(
setslotsize(heap_trigger%)
@
132,"Not enough room to extend block #"+
~anchor%
# heap_trigger%=trysize%
"SlidingHeap_ExtendBlock",slidingheapbase%,anchor%,newsize%
1trysize%=
_heap_pageup(
_heap_nextfree-&7FFC)
trysize%<>heap_trigger%
setslotsize(trysize%)
heap_trigger%=trysize%
"SlidingHeap_VerifyHeap",slidingheapbase%
_heap_bytes(b%)
end%
"OS_ConvertFixedFileSize",b%,block%,block%+&100
,end%
?end%=13
=$block%
_heap_bytes2(b%)
end%
"OS_ConvertFileSize",b%,block%,block%+&100
,end%
?end%=13
=$block%
create_fixed_block(size%)
pointer%,flag%
"XOS_Heap",2,fixedheapbase%,,size%
,,pointer%;flag%
flag%
extendfixedheap
"XOS_Heap",2,fixedheapbase%,,size%
,,pointer%;flag%
=pointer%
extendfixedheap
nshb%,extend%,trysize%
"OS_ReadMemMapInfo"
extend%
$trysize%=
_heap_slotsize+extend%
setslotsize(trysize%)
_heap_slotsize<trysize%
255,"No room to extend fixed heap"
"nshb%=slidingheapbase%+extend%
"SlidingHeap_ShiftHeap",slidingheapbase%,nshb%
"OS_Heap",5,fixedheapbase%,,extend%
fixedheapsize%+=extend%
slidingheapbase%=nshb%
"SlidingHeap_VerifyHeap",slidingheapbase%
------------Harriet's extra procedures--------------------------------------
FontMenu(tickme$)
menubuf%,indirbuf%,f%
$(block%+&100)=tickme$
"Hourglass_On"
"Font_ListFonts",,0,&C0000,-1,0
,,,menubuf%,,indirbuf%
find block size required
extend_named_sliding_block(fontmenu%,menubuf%)
extend_named_sliding_block(indir%,indirbuf%)
"Font_ListFonts",,!fontmenu%,%101100<<16,menubuf%,!indir%,indirbuf%,block%+&100
"Hourglass_Off"
fontM%=!fontmenu%
highfontM%!32=fontM%
highfontM%!56=fontM%
highfontM%!80=fontM%
in case menu structure has moved in memory
checkfontsOK
lose_fonts
f%=1
ifthere("Font:"+font$(f%))=0
check for existence of directory on Font$Path
wimpy_error(0,"Font "+
(34)+font$(f%)+
(34)+" not found. It shall be replaced by ""Trinity.Medium""",
font$(f%)="Trinity.Medium"
font%(f%,0)=0
window%(mainW%,1)>0
f%=1
get_font(f%)
update_fontcontrols
ifthere(path$):
won't warn you of *open* files, only non-existent ones
"OS_File",17,path$
decodefontmenu(menustring$)
translate menu data into sensible font name
fontstart%
#fontstart%=
menustring$,"\f1 ")
fontstart%
*menustring$=
menustring$,fontstart%+4)
!#fontstart%=
menustring$,"\F")+2
"Pmenustring$=
menustring$,fontstart%,
menustring$,"\",fontstart%)-fontstart%)
=menustring$